﻿using Abp.Extensions;
using System.Text.RegularExpressions;

namespace Vecen.BangChuang.Validation {
    public static class ValidationHelper {
        public const string EmailRegex = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";

        /// <summary>
        /// 是否是邮箱
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsEmail(string value) {
            if(value.IsNullOrEmpty()) {
                return false;
            }

            var regex = new Regex(EmailRegex);
            return regex.IsMatch(value);
        }

        /// <summary>
        /// 是否是手机号
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsMobilePhone(string value) {
            if(value.IsNullOrEmpty()) {
                return false;
            }

            return Regex.IsMatch(value, @"^1[34578]\d{9}$", RegexOptions.IgnoreCase);
        }
    }
}